import {getCategoryList} from "@/api/category"

export default {
    namespaced: true,
    state: {
        categorys:[],
    },
    getters:{},
    mutations: {
        SET_CATEGORYS(state,value){
            state.categorys = value;
        }
    },
    actions:{
        //获取树形结构
        getCategorys({commit}){
            return new Promise((resolve,reject)=>{
                getCategoryList().then(({data})=>{
                    commit("SET_CATEGORYS",data.data);
                    resolve(data);
                }).catch(error=>{
                    reject(error);
                })
            })

        }
    },
  }


